<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<!--	<bean id="dataSource"-->
<!--		class="com.mchange.v2.c3p0.ComboPooledDataSource"-->
<!--		destroy-method="close">-->
<!--		<property name="driverClass" value="com.mysql.jdbc.Driver" />-->
<!--		<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/housekeepingtesting" />-->
<!--		<property name="user" value="root" />-->
<!--		<property name="password" value="" />-->
<!--		<property name="minPoolSize" value="2" />-->
<!--      	<property name="maxPoolSize" value="4" />-->
<!--	</bean>-->
	
	<bean id="hibernateSessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
<!--		<property name="configLocation" value="classpath:hibernate.cfg.xml"/>-->
		<property name="annotatedClasses">
			<list>
				<value>hdb.om.Artikel</value>
				<value>hdb.om.Einkaufsliste</value>
				<value>hdb.om.Vorrat</value>
				<value>hdb.om.LagerTyp</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
			</props>
		</property>
	</bean>
	
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
	</bean>
	
	<!-- ******************* -->
	<!-- Data Access Objekte -->
	<!-- ******************* -->
	
	<bean id="vorratDao" class="hdb.dao.VorratDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />		
	</bean>
	
	<bean id="artikelDao" class="hdb.dao.ArtikelDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
		<property name="vorratDao" ref="vorratDao" />		
	</bean>
	
	<bean id="lagertypDao" class="hdb.dao.LagerTypDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />
		<property name="vorratDao" ref="vorratDao" />			
	</bean>
	
	<bean id="einkaufslisteDao" class="hdb.dao.EinkaufslisteDao">
		<property name="sessionFactory" ref="hibernateSessionFactory" />		
	</bean>

	<!-- ************** -->
	<!-- Die Controller -->
	<!-- ************** -->
	
	<bean name="HomeCo" class="hdb.controller.Home" />
	
	<bean name="SearchArtikelCo" class="hdb.controller.SearchArtikel">
		<property name="artikelDao" ref="artikelDao"/>
	</bean>
	
	<bean name="NeuerArtikelCo" class="hdb.controller.EditArtikel">
		<property name="artikelDao" ref="artikelDao"/>
	</bean>
	
	<bean name="EditArtikelCo" class="hdb.controller.EditArtikel">
		<property name="artikelDao" ref="artikelDao"/>
	</bean>
	
	<bean name="SaveArtikelCo" class="hdb.controller.SaveArtikel">
		<property name="artikelDao" ref="artikelDao"/>
	</bean>
	
	<bean name="AlleArtikelCo" class="hdb.controller.AlleArtikel">
		<property name="artikelDao" ref="artikelDao"/>
	</bean>
	
	<bean name="LoescheArtikelCo" class="hdb.controller.LoescheArtikel">
		<description>hdb.controller.LoescheArtikel is a subclass of hdb.controller.AlleArtikel.
			This allows us to redirect to hdb.controller.AlleArtikel after deleting.
			The property artikelDao has to be set anyway.</description>
		<property name="artikelDao" ref="artikelDao"/>
	</bean>
	
	<bean name="NeuerLagerTypCo" class="hdb.controller.EditLagerTyp">
		<property name="lagertypDao" ref="lagertypDao"/>
	</bean>

	<bean name="EditLagerTypCo" class="hdb.controller.EditLagerTyp">
		<property name="lagertypDao" ref="lagertypDao"/>
	</bean>

	<bean name="SaveLagerTypCo" class="hdb.controller.SaveLagerTyp">
		<property name="lagertypDao" ref="lagertypDao"/>
	</bean>
	
	<bean name="AlleLagerTypCo" class="hdb.controller.AlleLagerTyp">
		<property name="lagertypDao" ref="lagertypDao"/>
	</bean>
	
	<bean name="LoescheLagerTypCo" class="hdb.controller.LoescheLagerTyp">
		<description>hdb.controller.LoescheLagerTyp is a subclass of hdb.controller.AlleLagerTyp.
			This allows us to redirect to hdb.controller.AlleLagerTyp after deleting.
			The property lagertypDao has to be set anyway.</description>
		<property name="lagertypDao" ref="lagertypDao"/>
	</bean>
	
	<bean name="StartVorratCo" class="hdb.controller.StartVorrat">
		<property name="artikelDao" ref="artikelDao"/>
	</bean>
	
	<bean name="EditVorratCo" class="hdb.controller.EditVorrat">
		<property name="artikelDao" ref="artikelDao"/>
		<property name="lagertypDao" ref="lagertypDao"/>
		<property name="vorratDao" ref="vorratDao"/>
	</bean>
	
	<bean name="SaveVorratCo" class="hdb.controller.SaveVorrat">
		<property name="vorratDao" ref="vorratDao"/>
	</bean>
	
	<bean name="AlleVorratCo" class="hdb.controller.AlleVorrat">
		<property name="vorratDao" ref="vorratDao"/>
	</bean>
	
	<bean name="LoescheVorratCo" class="hdb.controller.LoescheVorrat">
		<description>hdb.controller.LoescheVorrat is a subclass of hdb.controller.AlleVorrat.
			This allows us to redirect to hdb.controller.AlleVorrat after deleting.
			The property vorratDao has to be set anyway.</description>
		<property name="vorratDao" ref="vorratDao"/>
	</bean>
	
	<bean name="NeueEinListeCo" class="hdb.controller.EditEinkaufsliste">
		<property name="einkaufslisteDao" ref="einkaufslisteDao"/>
	</bean>	
</beans>
